/*
 * DyingPacMan.fx
 *
 * Created on 19/03/2010, 02:05:03 AM
 */

package util;

/**
 * @author Alex
 */

import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.scene.shape.Arc;

/**
 
 */

public class DyingPacMan extends Arc {

   public var maze : Maze;

   var timeline = Timeline {
      repeatCount: 1
      keyFrames: [

        KeyFrame {
           time: 600ms
           action: function() {
              // hide the pacMan character and ghosts before the animation
              maze.pacMan.visible = false;

              for ( g in maze.ghosts ) {
                 g.hide();
               }

              visible = true;
            }
           values: [ startAngle => 90, length=>360 ];
         },
  
        KeyFrame {
           time: 1800ms
           action: function() {
              visible = false;
            }
           values: [ startAngle => 270 tween Interpolator.LINEAR,
                     length => 0 tween Interpolator.LINEAR ]
         },
      ]
    }

   public function startAnimation(x: Number, y: Number) : Void {

      startAngle = 90;
      centerX = x;
      centerY = y;

      timeline.play();
    }
}